package com.liyi.letter.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @program: letter_parent
 * @description 自动填充时间字段
 * @author: tianwen
 * @create: 2023-06-06 10:28
 **/
@Configuration
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("公共字段自动填充[insert]。。。");
        log.info(metaObject.toString());
        metaObject.setValue("createdTime", new Date());
        metaObject.setValue("updatedTime",new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("公共字段自动填充[update]。。。");
        log.info(metaObject.toString());
        metaObject.setValue("updatedTime",new Date());
    }
}

